<?php
session_start();
    
/*
 * This will be the getting of all sub route id and name. 
 * This is being used by admRouteCreate.php
 * 
 * Created by: Peter Agno Jr.
 * Date created: December 6, 2011
 */

    include('../includes/siteConfig.php');
    // CONNECT TO DATABASE
    $connect = mysql_connect($hostName,$rootName,$dBasePassword) or die ('Unable to connect!');
    mysql_select_db($dBaseName) or die ('Unable to select database!');
    
    
    // GET PREVIOUS STEP ID BY CHECKING LOGS
    $query = 
        "
            SELECT *
            FROM SubRoute
        ";
    
    $result = mysql_query($query) or die ('Error in query: $query. ' . mysql_error());
     
    
    if (mysql_num_rows($result) > 0) {
        // SAVE QUERY RESULTS TO AN ARRAY > $row. Each row will be placed to a list ($permissionList).  
        while ($row = mysql_fetch_array($result)) {
            $data = array();
            $data['subRouteId'] = $row['subRouteId'];
            $data['subRouteName'] = $row['subRouteName'];

            $list[] = $data;
        }

        echo json_encode($list);
    }
    
    else {
        echo json_encode(0);
    }
    
    mysql_free_result($result);
    mysql_close($connect);
?>
<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
?>
